package com.bestv.bsr.core.service;

import com.bestv.bsr.core.properties.GlobalProperties;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author taojiacheng
 */
public abstract class AbstractRecommendEngine implements IRecommendEngine, InitializingBean {

    protected Set<String> supportedAiSources = new HashSet<>();

    @Autowired
    protected GlobalProperties globalProperties;


    @Override
    public boolean accept(String... aiSources) {
        for (String aiSource : aiSources) {
            if (supportedAiSources.contains(aiSource)) {
                return true;
            }
        }
        return false;
    }

    @Override
    public void afterPropertiesSet() {
        supportedAiSources.addAll(addSupportedAiSource());
    }

    protected abstract List<String> addSupportedAiSource();

}
